import React from 'react';
import './index.less';
import {connect} from "dva";
import Curd from "components/Curd";
import createColumns from './columns';
import {searchColumns} from './searchColumns'
import {getLabel, getValues} from "assets/const/city";


@connect(({hospital, area}) => ({hospital, area}))
export default class extends Curd {

  getNamespace() {
    return 'hospital';
  }

  getTableColumns() {
    return createColumns(this);
  }

  getSearchColumns() {
    return searchColumns(this);
  }

  onUpdate(record){
    const r = { ...record, city: getValues(record.city)};
    super.onUpdate(r);
  }

  getArea = () => {
    const {all, loadingAll} = this.getModel("area");

    const dict = (!!all && all.length > 0) ? all.map(v => {
      return ({code: v.id, codeName: v.name})
    }) : undefined;

    return ({loading: loadingAll, dict});
  }
}
